<script type="text/javascript">
var content = null;
$(function () {
	//页签
	$('#tabs').tabs();
	//ckeditor
	if(CKEDITOR.instances['content']) 
		CKEDITOR.remove(CKEDITOR.instances['content']);
	var uploadParm = {
		height:'150px',
		filebrowserBrowseUrl:'${contextPath}browse-file.html',
		filebrowserImageBrowseUrl:'${contextPath}browse-image.html',
		filebrowserUploadUrl:'${contextPath}m/organOrgan-upload.html?type=file',
		filebrowserImageUploadUrl:'${contextPath}m/organOrgan-upload.html?type=image',
		language:'zh-cn'
	}
	content = CKEDITOR.replace('content', uploadParm);
	//引js
	var url = '${contextPath}script/sys/organOrgan.js?time=' + sys_get_time();
	$.ajax({url:url, dataType:'script', cache:true,
		success: function(){
			//上传
			addFilesUploadEvent("1", '${contextPath}upload/organSynopsisAnnex/');
			addFilesUploadEvent("2", '${contextPath}upload/organSynopsisAnnex/');
			addFilesUploadEvent("3", '${contextPath}upload/organSynopsisAnnex/');
			addFilesUploadEvent("4", '${contextPath}upload/organSynopsisAnnex/');
			
		}
	});
	//限制只能展示3张图片
	$('input[type=checkbox]').click(function(){
		if ($("input[type=checkbox]:checked").length > 3) {
		  $(this).attr('checked',false);
          $(this).val('false');
          sys_msg('只能够选择3张图作为展示');
          return
	    } 
		if($(this).attr("checked") == 'checked'){
			$(this).val('true');
		}else{
			$(this).val('false');
		}
	})
});

var map;
var  marker;
function init() {
	var d = new Date();
	var position = new AMap.LngLat(parseFloat(<#if longitude?? &&  longitude != "">${(longitude)!''}<#else>106.710237</#if>), parseFloat(<#if latitude?? &&  latitude != "">${(latitude)!''}<#else>26.533338</#if>));//创建中心点坐标, 贵阳小城故事为中心
    map = new AMap.Map("mapDiv", {
		center : position,
		level : 15  //地图显示的缩放级别
	});
	marker = new AMap.Marker({     
     });     
	marker.setMap(map); 
	//添加寻找坐标的click事件
	var clickEventListener=AMap.event.addListener(map,'contextmenu',function(e){  
	        $("#lo").val(e.lnglat.getLng());  
	        $("#la").val(e.lnglat.getLat()); 
	        clickGetPoits_organOrgan(e.lnglat.getLng(),e.lnglat.getLat());
        }); 
	//加载工具条
	map.plugin([ "AMap.ToolBar",  "AMap.Autocomplete",  "AMap.DragRoute", "AMap.Hotspot","MapType"],
			function() {
				var tool = new AMap.ToolBar();
				var type= new AMap.MapType({defaultType:0});//初始状态使用2D地图  
      		    map.addControl(type); 
				map.addControl(tool);
			});
	createMarkers(${(od)!"[]"}, map);
}
$('#editOrganForm').find("input:checkbox, input:radio").not('input.ibtn').uniform();

</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<form id="editOrganForm">
 <div class="widgetcontent">
	<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<ul>
			<li><a href="#tabs-1">公司基本信息</a></li>
			<li><a href="#tabs-2">公司简介</a></li>
			<li><a href="#tabs-3">显示图片</a></li>
			<li><a href="#tabs-4" onclick="javascript:loadScript();return false;">选择经纬度</a></li>
		</ul>
		<div id="tabs-1">
			<table class="table boo-table table-content" >
				<tr>
					<td class="table-left">上级机构</td>
					<td>
						<input type="hidden" name="pc" id="pc" value="${(organ.pc)!'0'}" />
						<input class="form-control" type="text" name="pn" id="pn" value="${(organ.pn)!''}" readonly="readonly">
					</td>
				</tr>
				<tr>
					<td class="table-left" style="width:100px;">名称</td>
					<td><input class="form-control" type="text" id="name" name="name" value="${(organ.name)!''}"/>
						<input class="form-control" type="hidden" id="code" name="code" value="${(organ.code)!''}" />
						<input  type="hidden" name="details.code" value="${(organ.details.code)!''}" />
					</td>
				</tr>
				<tr>
					<td class="table-left">简称</td>
					<td><input class="form-control" type="text" id="abbname" name="abbname" value="${(organ.abbname)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">网址</td>
					<td><input class="form-control" type="text" id="site" name="details.site" value="${(organ.details.site)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">电话</td>
					<td><input class="form-control" type="text" id="phone" name="details.phone" value="${(organ.details.phone)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">传真</td>
					<td><input class="form-control" type="text" id="fax" name="details.fax" value="${(organ.details.fax)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">Email</td>
					<td><input class="form-control" type="text" id="email" name="details.email" value="${(organ.details.email)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">地址</td>
					<td><input class="form-control" type="text" id="address" name="details.address" value="${(organ.details.address)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">邮编</td>
					<td><input class="form-control" type="text" id="postal" name="details.postal" value="${(organ.details.postal)!''}" style="width:80px;" /></td>
				</tr>
				<tr>
					<td class="table-left">负责人</td>
					<td><input class="form-control" type="text" id="manager" name="manager" value="${(organ.manager)!''}"/></td>
				</tr>
				<tr>
					<td class="table-left">机构类型</td>
					<td><#if (organ?? && '' != organ.pc)>
							<#if (organ.pc?? && '0' != organ.pc)>
								<@mte.OrganType value=((organ.otc)!"") id='otc' name='otc' pc=((organ.otc)!'')/>
							<#else>
								${(organ.otn)!''}
							</#if>
						<#else>
							<@mte.OrganType value=((organ.otc)!"") id='otc' name='otc' pc=((organ.otc)!'')/>
						</#if>
					</td>
				</tr>
				<tr>
					<td class="table-left">是否屏蔽</td>
					<td><@mt.YesOrNo value=((organ.deleted)!false) r=true name='deleted' d=false mc=false /></td>
				</tr>
				<tr>
					<td>是否使用</td>
					<td><@mt.YesOrNo value=((organ.isUsing)!false) r=true name='isUsing' d=false mc=false /></td>
				</tr>
			</table>
		</div>
		<div id="tabs-2">
			<textarea id="content">${(organ.synopsis.content)!''}</textarea>
			<input type="hidden" name="synopsis.oc" value="${(organ.synopsis.oc)!''}"/>
			<input type="hidden" name="synopsis.code" value="${(organ.synopsis.code)!''}"/>
		</div>
		<div id="tabs-3">
			<table class="table boo-table table-content">
			<font style="color: red;">LOGO图、背景图、首页图都只能上传一张哦</font>
			<#assign i = 0/>
				<tr>
					<td class="table-left">LOGO<a id="uploadFilesBtn1" p="4" href="javascript:;" >[选择]</a></td>
					<td id="annexListTable1">
						<#if list??>
							<#list list as osa>
							<#if osa?? && osa.type == 1>
								<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
									<input type="hidden" name="list[${osa_index}].code" value="${osa.code}" />
									<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert" >&times;</button></div>
									<img class="imgs" style="width:150px;height:150px;" src="${contextPath}upload/organSynopsisAnnex/${osa.sn}"/>
									<input class="type" type="hidden" value="${osa.type}"/>
								</div>
								<#assign i = i + 1/>
								</#if>
							</#list>
						</#if>
					</td>
				</tr>
				<tr>
					<td class="table-left">背景<a id="uploadFilesBtn2" p="4" href="javascript:;" >[选择]</a></td>
					<td id="annexListTable2">
						<#if list??>
							<#list list as osa>
							<#if osa?? && osa.type == 2>
								<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
									<input type="hidden" name="list[${osa_index}].code" value="${osa.code}" />
									<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert" >&times;</button></div>
									<img class="imgs" style="width:150px;height:150px;" src="${contextPath}upload/organSynopsisAnnex/${osa.sn}"/>
									<input class="type" type="hidden" value="${osa.type}"/>
								</div>
								<#assign i = i + 1/>
								</#if>
							</#list>
						</#if>
					</td>
				</tr>
				<tr>
					<td class="table-left">首页图<a id="uploadFilesBtn3" p="4" href="javascript:;" >[选择]</a></td>
					<td id="annexListTable3">
						<#if list??>
							<#list list as osa>
							<#if osa?? && osa.type == 3>
								<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
									<input type="hidden" name="list[${osa_index}].code" value="${osa.code}" />
									<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert" >&times;</button></div>
									<img class="imgs" style="width:150px;height:150px;" src="${contextPath}upload/organSynopsisAnnex/${osa.sn}"/>
									<input class="type" type="hidden" value="${osa.type}"/>
								</div>
								<#assign i = i + 1/>
								</#if>
							</#list>
						</#if>
					</td>
				</tr>
				<tr>
					<td class="table-left">展示图片<a id="uploadFilesBtn4" p="4" href="javascript:;" onclick="javascript: addFilesUploadEvent('${contextPath}upload/organSynopsisAnnex/');" >[选择]</a></td>
					<td id="annexListTable4">
						<#if list??>
							<#list list as osa>
							<#if osa?? && osa.type == 4>
								<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
									<input type="hidden" name="list[${osa_index}].code" value="${osa.code}" />
									<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert" >&times;</button></div>
									<img class="imgs" style="width:150px;height:150px;" src="${contextPath}upload/organSynopsisAnnex/${osa.sn}"/>
									<p style="margin: 0px;"><input class="cover" type="checkbox" name="list[${osa_index}].cover" value="${(osa.cover)!''}" <#if osa?? && osa.cover==true>checked="checked"</#if> /></p>
									<input class="type" type="hidden" value="${osa.type}"/>
								</div>
								<#assign i = i + 1/>
								</#if>
							</#list>
						</#if>
					</td>
				</tr>
				
			</table>
		</div>
		
		<div id="tabs-4" >
			<table class="table boo-table table-content">
				<tr>
					<th>经度</th>
					<td><input type="text" id="longitude" name="details.longitude" value="${(organ.details.longitude)!''}" style="width:150px;"/>
					</td>
					<th>纬度</th>
					<td><input type="text" id="latitude" name="details.latitude" value="${(organ.details.latitude)!''}" style="width:150px;"/>
						<a class="btn btn-info" href="javascript:;" onclick="crawlPoint_organOrgan();return false;" ><i class="icon-floppy"></i>抓取坐标</a>
						<input type="hidden" id="lo"  value="${(organ.details.longitude)!''}"/>
						<input type="hidden" id="la"  value="${(organ.details.latitude)!''}"/>
					</td>
				</tr>
			</table>
			<div  id="mapDiv" style="width:100%;height:400px;" class="myMap" >
				
			</div>
			<div>使用右上角的地图切换插件进行地图类型切换</div>
		</div>
		<div style="text-align:center;">
			<a class="btn btn-info" href="javascript:;" onclick="javascript:saveOrgan();"><i class="icon-floppy"></i> 保 存</a>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<a class="btn btn-info" href="javascript:;" onclick="javascript:sys_load_handle('organOrgan');"><i class="icon-block"></i> 取 消</a>
		</div>
	</div>
</div>
</form>

<div id="tempAnnexListDiv" style="display:none;">
	<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
		<input class="name" type="hidden" />
		<input class="size" type="hidden" />
		<input class="sn" type="hidden"  />
		<input class="ext" type="hidden"  />
		<input class="afcs" type="hidden" name="afcs"  />
		<input class="type" type="hidden"/>
		<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert">&times;</button></div>
		<img class="imgs" style="width:150px;height:150px;" />
	</div>
</div>
<div id="tempAnnexListDiv4" style="display:none;">
	<div class="filter-table rep img001" style="margin-left:5px; margin-bottom:5px;">
		<input class="name" type="hidden" />
		<input class="size" type="hidden" />
		<input class="sn" type="hidden"  />
		<input class="ext" type="hidden"  />
		<input class="afcs" type="hidden" name="afcs"  />
		<input class="type" type="hidden"/>
		<div class="guanbi" onclick="javascript:deleteSelectedItem($(this));"><button type="button" class="close" data-dismiss="alert">&times;</button></div>
		<img class="imgs" style="width:150px;height:150px;" />
		<p style="margin: 0px;"><input type="checkbox" class="cover" value="false" /></p>
	</div>
</div>
<input type="hidden" id="organOrgan_an_index" value="${i}" />
